package com.frank.wcld.zfjd.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.wcld.zfjd.domain.WcldZfjd;
import com.frank.wcld.zfjd.service.IWcldZfjdService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 执法监督Controller
 * 
 * @author frank
 * @date 2025-08-27
 */
@Controller
@RequestMapping("/wcld/zfjd")
public class WcldZfjdController extends BaseController
{
    private String prefix = "wcld/zfjd";

    @Autowired
    private IWcldZfjdService wcldZfjdService;

    @RequiresPermissions("wcld:zfjd:view")
    @GetMapping()
    public String zfjd()
    {
        return prefix + "/zfjd";
    }

    /**
     * 查询执法监督列表
     */
    @RequiresPermissions("wcld:zfjd:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WcldZfjd wcldZfjd)
    {
        startPage();
        List<WcldZfjd> list = wcldZfjdService.selectWcldZfjdList(wcldZfjd);
        return getDataTable(list);
    }

    /**
     * 导出执法监督列表
     */
    @RequiresPermissions("wcld:zfjd:export")
    @Log(title = "执法监督", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WcldZfjd wcldZfjd)
    {
        List<WcldZfjd> list = wcldZfjdService.selectWcldZfjdList(wcldZfjd);
        ExcelUtil<WcldZfjd> util = new ExcelUtil<WcldZfjd>(WcldZfjd.class);
        return util.exportExcel(list, "执法监督数据");
    }

    /**
     * 新增执法监督
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存执法监督
     */
    @RequiresPermissions("wcld:zfjd:add")
    @Log(title = "执法监督", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WcldZfjd wcldZfjd)
    {
        wcldZfjd.setCreateBy(getLoginName());
        return toAjax(wcldZfjdService.insertWcldZfjd(wcldZfjd));
    }

    /**
     * 修改执法监督
     */
    @RequiresPermissions("wcld:zfjd:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WcldZfjd wcldZfjd = wcldZfjdService.selectWcldZfjdById(id);
        mmap.put("wcldZfjd", wcldZfjd);
        return prefix + "/edit";
    }

    /**
     * 修改保存执法监督
     */
    @RequiresPermissions("wcld:zfjd:edit")
    @Log(title = "执法监督", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WcldZfjd wcldZfjd)
    {
        wcldZfjd.setUpdateBy(getLoginName());
        return toAjax(wcldZfjdService.updateWcldZfjd(wcldZfjd));
    }

    /**
     * 删除执法监督
     */
    @RequiresPermissions("wcld:zfjd:remove")
    @Log(title = "执法监督", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wcldZfjdService.deleteWcldZfjdByIds(ids));
    }
}
